package com.android.BluethootChess.rules;

import java.util.ArrayList;
import java.util.List;

import android.graphics.Point;

import com.android.BluethootChess.model.GameBoardMatrix;
import com.android.BluethootChess.model.PieceColor;

/**
 * BishopRules clasa care extinde class PieceRule si
 * defineste regulile pentru piesa nebun.
 * 
 * @see PieceRule
 */
public class NewBishopRules extends PieceRule {


	public NewBishopRules(GameBoardMatrix matrix, PieceColor pieceColor) {
		super(matrix, pieceColor);
	}

	public List<Point> findAllAvaiblePositions() {
		List<Point> list = new ArrayList<Point>();

		int pieceLine = piecePosition.x;
		int pieceCol = piecePosition.y;

		int index = 1;
		while (isValidLocation(pieceLine + index, pieceCol + index)) {
			list.add(new Point(pieceLine + index, pieceCol + index));
			index++;
		}

		index = 1;
		while (isValidLocation(pieceLine - index, pieceCol - index)) {
			list.add(new Point(pieceLine - index, pieceCol - index));
			index++;
		}
		
		index = 1;
		while (isValidLocation(pieceLine - index, pieceCol + index)) {
			list.add(new Point(pieceLine - index, pieceCol + index));
			index++;
		}
		
		index = 1;
		while (isValidLocation(pieceLine + index, pieceCol - index)) {
			list.add(new Point(pieceLine + index, pieceCol - index));
			index++;
		}
		
		
		return list;
	}

}
